MQTT Essentials - A Lightweight IoT Protocol by Gaston C. Hillar

MQTT Essentials - A Lightweight IoT Protocol by Gaston C. Hillar

Author:Gaston C. Hillar [Hillar, Gaston C.]
Language: eng
Format: azw3, pdf
Publisher: Packt Publishing
Published: 2017-04-14T04:00:00+00:00


In MQTT.fx, click Publish and enter commands/drone01 in the dropdown on the left-hand side of the Publish button. Click QoS 2 because we want to use a QoS level of 2.

Enter the following text in the textbox below the Publish button: {"COMMAND": "SET_MAX_ALTITUDE", "FEET": 20}.

Then, click the Publish button. MQTT.fx will publish the entered text to the specified topic with a QoS level of 2.

Go to the window in which you can see the output generated by the Python code. In case you are running the code in an IoT board, you might be using an SSH Terminal. In case you are running the code on your local computer, go to the Terminal or Command Prompt, based on the operating system you are using. You will see the following output:

Connected to the MQTT server I've received the following message: {"COMMAND": "SET_MAX_ALTITUDE", "FEET": 20} drone01: Setting maximum altitude to 20 feet

The code has received the message with the command, the Drone instance executed the set_max_altitude method with 20 as an argument, and the output displays the results of executing this code.

Go back to MQTT.fx, click Subscribe, and you will see a new message has arrived to the processedcommands/drone01 topic with the following payload: {"SUCCESSFULLY_PROCESSED_COMMAND": "SET_MAX_ALTITUDE"}. The following screenshot shows the received message in MQTT.fx:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.